<template>
  <div class="login" :class="[isDesktop ? 'pc' : 'h5']">
    <div class="login-container">
      <div class="login-logo">
        <img v-if="logo" :src="logo" alt="logo" />
        <img v-else src="/logo.svg" alt="logo" />
        <span style="color: var(--color-login-text);">{{ title }}</span>
      </div>
      <a-row align="stretch" class="login-box">
        <div class="login-right">
          <a-tabs class="login-right__form">
            <a-tab-pane key="1" title="账号登录">
              <AccountLogin />
            </a-tab-pane>
          </a-tabs>
        </div>
      </a-row>
      <div v-if="isDesktop" class="footer">
        <div class="beian">
          <div class="below text">
            {{ appStore.getCopyright() }}{{ appStore.getForRecord() ? ` ·
            ${appStore.getForRecord()}` : '' }}
          </div>
        </div>
      </div>
    </div>
    <GiThemeBtn class="theme-btn" @themeChanged="handleThemeChange" />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import AccountLogin from './components/account/index.vue'
import { useAppStore } from '@/stores'
import { useDevice } from '@/hooks'


const appStore = useAppStore()
const { isDesktop } = useDevice()
const title = computed(() => appStore.getTitle())
const logo = computed(() => appStore.getLogo())
const isDarkTheme = ref(false);

const handleThemeChange = (isDark: boolean) => {
  isDarkTheme.value = isDark
  document.body.classList.toggle('dark', isDarkTheme.value)
}
</script>

<style scoped lang="scss">
.login {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-image: url('/public/static/images/login_bg.png');
  /* 替换为你的背景图路径 */
  background-color: var(--color-bg-5);
  background-size: cover;
  /* 使背景图覆盖整个容器 */
  background-position: center;
  /* 使背景图居中 */
  background-repeat: no-repeat;
  /* 防止背景图重复 */
  color: var(--color-login-text);

  .login-container input,
  .login-container textarea,
  .login-container select{
    background-color: var(--input-bg-color,#ffffff);
    color: var(--color-login-text);
  }

  &-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 35px; /* 可以根据需要调整内边距 */
    border-radius: 25px; /* 可以根据需要���整圆角 */
    box-shadow: 100px 10px 200px rgba(0, 0, 0, 0.2); /* 可以根据需要调整阴影效果 */
    max-width: 400px; /* 可以根据需要调整最大宽度 */
    width: 100%;
    margin: 0 auto; /* 居中对齐 */
    background-color: var(--form-bg-color);
    color: var(--color-login-text);
    transition: background-color 0.3s, color 0.3s;
    min-width: 300px;
  }

  &-logo {
    width: 100%;
    height: auto; // 根据需求调整高度
    font-weight: 700;
    font-size: 20px;
    line-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;

    img {
      width: 34px;
      height: 34px;
      margin-right: 8px;
    }
  }

  &-box {
    width: 100%;
    max-width: 800px;
    display: flex;
    z-index: 999;
    box-shadow: 0 2px 4px 2px rgba(0, 0, 0, 0.08);
  }

  &-right {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 30px;
    box-sizing: border-box;

    &__form {
      // 样式调整
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      box-sizing: border-box;
    }
  }
}

.pc {
  // 桌面端特有样式
}

.h5 {

  // 移动端特有样式
  .login-logo {
    // 移动端 logo 样式调整
  }
}

.theme-btn {
  position: fixed;
  top: 20px;
  right: 30px;
  z-index: 9999;
}

.footer {
  align-items: center;
  box-sizing: border-box;
  position: absolute;
  bottom: 10px;
  z-index: 999;

  .beian {
    .text {
      font-size: 12px;
      font-weight: 400;
      letter-spacing: 0.2px;
      line-height: 20px;
      text-align: center;
      color: var(--color-login-text);

      &.dark{
        background-color:#1e1e1e;
        color: #ffffff;
      }
    }
  }
}
</style>
